2020/11/11

Data Cleaning

Separate the county data;

separate statewide data;

sum projectAmount;

federalShareObligated by disaster and county;

federalShareObligated by disaster and state.
disaster region subregion date projectAmount federalShare
1866 alabama baldwin 2009-12-22 3066594.49 2299945.88
1866 alabama mobile 2009-12-22 1184470.36 888352.78
1931 texas calhoun 2010-08-03 334817.02 251112.77
1931 texas cameron 2010-08-03 2256055.79 1692042.00
1931 texas cottle 2010-08-03 95463.76 71597.84
1931 texas dawson 2010-08-03 705461.25 529095.98

prepare location & prepare map data

#> # A tibble: 6 x 6
#>   storm_id    usa_atcf_id date         latitude longitude  wind
#>   <chr>       <chr>       <chr>           <dbl>     <dbl> <dbl>
#> 1 Harvey-2017 AL092017    201708160600     13.7     -45.8    25
#> 2 Harvey-2017 AL092017    201708161200     13.7     -47.4    25
#> 3 Harvey-2017 AL092017    201708161800     13.6     -49      25
#> 4 Harvey-2017 AL092017    201708170000     13.6     -50.6    25
#> 5 Harvey-2017 AL092017    201708170600     13.4     -52      25
#> 6 Harvey-2017 AL092017    201708171200     13.1     -53.4    30
#> # A tibble: 6 x 6
#>   storm_id   usa_atcf_id date         latitude longitude  wind
#>   <chr>      <chr>       <chr>           <dbl>     <dbl> <dbl>
#> 1 Sandy-2012 AL182012    201210211800     14.3     -77.4    25
#> 2 Sandy-2012 AL182012    201210220000     13.9     -77.8    25
#> 3 Sandy-2012 AL182012    201210220600     13.5     -78.2    25
#> 4 Sandy-2012 AL182012    201210221200     13.1     -78.6    30
#> 5 Sandy-2012 AL182012    201210221800     12.7     -78.7    35
#> 6 Sandy-2012 AL182012    201210230000     12.6     -78.4    40

The code for Making a map plot of Hurricane Harvey’s received federal funds by county.

harveyPlot <- ggplot() + 
  geom_polygon(data=MainStates, aes(x=long, y=lat, group=group),
               colour="black",fill="white") + 
  geom_polygon(data=harvey, aes(x = long, y = lat, group = group, 
                                fill = cut)) + 
  scale_fill_brewer(palette="Blues") + 
  labs(fill="proportion of obligated fedral fund") + 
  geom_path(data=Track_Harvey,aes(longitude, latitude),color="red") + 
  ggtitle("Harvey-2017") + 
  xlim(c(-110, -65)) + 
  ylim(c(25, 50)) +
  theme(plot.title = element_text(hjust = 0.5))

Harvey Plot

We define federalShare/projectAmount as a value, which means the proportion of federal reimbursement for the entire project.

harveyPlot

The code of Making a map plot of Hurricane Sandy’s received federal funds by county

sandyPlot <- ggplot() + 
  geom_polygon(data=MainStates, aes(x=long, y=lat, group=group),
               colour="black",fill="white")+
  geom_polygon(data=sandy, aes(x = long, y = lat, group = group,
                               fill = cut))+
  scale_fill_brewer(palette="yellows")+
  geom_path(data=Track_Sandy, aes(longitude, latitude),color="red")+
  labs(fill="proportion of obligated fedral fund") + 
  ggtitle("Sandy-2012") +
  xlim(c(-110, -65)) + 
  ylim(c(25, 50)) +
  theme(plot.title = element_text(hjust = 0.5))

The Sandy Plot

In this polt, we also define federalShare/projectAmount as a value, which means the proportion of federal reimbursement for the entire project.

sandyPlot

The total fund of each state

After analyzing the two hurricanes, we also want to show the overall financial assistance of each state in recent years.

kable(head(stateFund)) %>% kable_classic()
disaster region date projectAmount federalShare
1866 alabama 2009-12-22 1295952.5 1040641.4
1931 texas 2010-08-03 10946932.8 8386169.9
1939 virgin islands of the u.s. 2010-09-28 4035930.3 3045021.4
3314 north carolina 2010-09-01 311721.4 237971.6
3315 massachusetts 2010-09-02 311462.5 234000.4
3326 puerto rico 2011-08-22 895780.3 671393.5

Plot total funds

ggplot(data = stateFund) +
  geom_point(aes(x = date, y = federalShare/projectAmount,
                 color = region))